package com.baofu.paycore.service.facade.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 支付服务码
 * <p>
 *     1、支付
 *     2、充值
 *     3、提现
 *     4、转账
 *     5、退款
 *     6、预授权
 *     7、预授权确认
 *     8、预授权撤销
 *     9、撤销
 *     10、线下打款充值
 *     11、解冻提现
 * </p>
 * User: LZQ Date: 2016/04/21  Version: 1.0
 */
@Slf4j
@Getter
@AllArgsConstructor
public enum ServiceCodeEnum {

    PAY("PAY","01", "支付"),

    RECHARGE("RECHARGE","02", "充值"),

    WITHDRAW("WITHDRAW","03", "提现"),

    TRANSFER("TRANSFER","04","转账"),

    REFUND("REFUND","05", "退款"),

    AUTH("AUTH","06", "预授权"),

    AUTH_CONFIRM("AUTH_CONFIRM","07", "预授权确认"),

    AUTH_CANCEL("AUTH_CANCEL","08", "预授权撤销"),

    CANCEL("CANCEL", "09", "撤销"),

    OFFLINE_RECHARGE("OFFLINE_RECHARGE","10", "线下打款充值"),

    UNFRE_WITHDRAW("UNFRE_WITHDRAW","11","解冻提现"),

    ISSUE_WITHDRAW("ISSUE_WITHDRAW","12","下发解冻提现"),

    FREEZE("FREEZE","13","冻结"),

    UNFREEZE("UNFREEZE","14","解冻"),

    UNFRE_TRANSFER("UNFRE_TRANSFER","15","解冻转账");

    /**
     * 枚举编码
     */
    private String code;

    /**
     * payNo 预留号
     */
    private String number;

    /**
     * 描述说明
     */
    private String description;

    /**
     * 通过枚举编码获得枚举
     *
     * @param code    枚举编码
     * @return        返回编码对应的枚举类型
     */
    public static ServiceCodeEnum explain(String code) {
        for (ServiceCodeEnum serviceCodeEnum : values()) {
            if (serviceCodeEnum.getCode().equals(code)) {
                return serviceCodeEnum;
            }
        }
        log.error("支付服务码异常，异常信息:{}", code);
        return null;
    }

}
